// import request from '../utils/request';

export function getHistory(userId: string) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: "http://localhost:3000/api/customerService/history", // 或 http://192.168.x.x:3000/api/customerService/history
      method: "GET",
      data: { userId },
      success: (res) => resolve(res.data),
      fail: (err) => reject(err),
    });
  });
}

export function sendMessage(data: any) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: "http://localhost:3000/api/customerService/send", // 或 http://192.168.x.x:3000/api/customerService/send
      method: "POST",
      data,
      success: (res) => resolve(res.data),
      fail: (err) => reject(err),
    });
  });
}

export function getAllMessages() {
  return new Promise((resolve, reject) => {
    uni.request({
      url: "http://localhost:3000/api/customerService/allMessages",
      method: "GET",
      success: (res) => resolve(res.data),
      fail: (err) => reject(err),
    });
  });
}
